package greed.P1109;/*
 *   exercise
 *   greed.P1109
 *
 *   description:
 *   @data 2025/5/13     下午3:34
 *   @author 凉风
 */

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] g = new int[n];
        for (int i = 0; i < n; i++) {
            g[i] = sc.nextInt();
        }
        int l = sc.nextInt();
        int r = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += g[i];
        }
        if(sum < l * n || sum > r * n) System.out.println("-1");
        else {
            List<Integer> larger = new ArrayList<>();
            List<Integer> lower = new ArrayList<>();
            int large = 0;
            int low = 0;
            for (int i = 0; i < n; i++) {
                if(g[i] > r) {
                    larger.add(g[i]);
                    large += g[i];
                }
                else if(g[i] < l) {
                    lower.add(g[i]);
                    low += g[i];
                }
            }
            int change = Math.max(large - r * larger.size(), l * lower.size() - low);
            System.out.println(change);
        }
    }
}
